﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace TestItemsSummary.Conveter
{
    public class BoolToVisibilityConveter : IValueConverter
    {
        //Source to target
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool? val;
            val = (bool)value;
            if (val!=null)
            {
                if (val == true)
                {
                    return Visibility.Visible;
                }
                else
                {
                    return Visibility.Collapsed;
                }
            }
            else
            {
               return Visibility.Visible;
            }
            //throw new NotImplementedException();
        }
        //Target to source
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // throw new NotImplementedException();
            return Binding.DoNothing;//no donothing
        }
    }
}
